<script type="text/javascript">
	$(document).ready(function() {
		$("#obtainlist").tablesorter({
			widthFixed: true,
			widgets: ['zebra']
		}).tablesorterPager({
			container: $(".pager")
		});
	});
</script>

<div id="main-content" class="prepend-1 span-19 last">
	<h3>Daftar Beasiswa Diterima</h3>
<?php 
	if (isset($result) && $result == FALSE) {
		echo '<span class="error">Status penerimaan gagal disimpan. Silakan coba beberapa saat lagi.</span>';
		echo '<div class="clear">'.nbs().'</div>';
	} else if (isset($result) && $result == TRUE) {
		echo '<span class="info">Status penerimaan berhasil disimpan.</span>';
		echo '<div class="clear">'.nbs().'</div>';
	}
?>
<?php echo form_open('mahasiswa/scholar/obtained', array('class' => 'form')); ?>
	<table id="obtainlist">
	<thead>
		<tr>
			<th>Nama Beasiswa</th>
			<th width="120">Awal Periode</th>
			<th width="120">Akhir Periode</th>
			<th width="100">Status</th>
			<th width="150">Status Pengiriman</th>
			<th width="150">Status Penerimaan</th>
		</tr>
	</thead>
	<tfoot>
		<?php echo $pager; ?>
	</tfoot>
	<tbody>
<?php
	$flag = FALSE; 
	if ($scholarships == NULL) :
?>
		<tr>
			<td align="center" colspan="6"><span class="info">Belum ada beasiswa didapatkan.</span></td>
		</tr>
<?php 
	else :
		foreach ($scholarships as $scholarship) :
?>
		<tr>
			<td><?php echo $scholarship->name; ?></td>
			<td align="center"><?php echo date(MONTH_YEAR_FORMAT, strtotime($scholarship->period_start)); ?></td>
			<td align="center"><?php echo date(MONTH_YEAR_FORMAT, strtotime($scholarship->period_end)); ?></td>
			<td align="center"><?php echo $scholarship->status; ?></td>
<?php 
	if ($scholarship->delivery == 'none') {
		echo '<td align="center">-</td>';
		echo '<td align="center">-</td>';
	} else if ($scholarship->delivery == 'sudah dikirim' || $scholarship->delivery == 'belum dikirim') {
		echo '<td align="center">'.$scholarship->delivery.'</td>';
	} else {
		echo '<td align="center">sudah dikirim</td>';
		echo '<td align="center">diterima</td>';
	}
	if ($scholarship->delivery == 'sudah dikirim') {
		$flag = TRUE;
?>
			<td align="center">
				<select name="<?php echo $scholarship->id; ?>">
					<option value="sudah dikirim" selected="selected">belum diterima</option>
					<option value="diterima">sudah diterima</option>
				</select>
			</td>
<?php 
	} else if ($scholarship->delivery == 'belum dikirim') {
		echo '<td align="center">-</td>';
	}
?>
		</tr>
<?php 
		endforeach;
	endif;
?>
	</tbody>
	</table>
<?php if ($flag) : ?>
	<input type="submit" class="submit" name="save" value="Simpan Status Penerimaan" style="float: right!important" />
<?php endif; echo form_close(); ?>
	<div class="clear"><?php echo nbs(); ?></div>
</div>